home *** CD-ROM | disk | FTP | other *** search
/ Pascal Super Library / Pascal Super Library (CW International)(1997).bin / REFERENC / TPR / SOURCE.EXE / DEMOTBUF.PAS < prev    next >
Pascal/Delphi Source File  |  1992-08-07  |  1KB  |  50 lines

  1. { DEMOTBUF.PAS }
  2. var
  3.   PhoneBook : PCollection;
  4.   PhoneBookFile : TBufStream;
  5.  
  6. ...
  7.  
  8.  
  9. { TPersonInfo is a collection object holding name and address information }
  10. procedure TPersonInfo.Store ( var S : TStream );
  11. begin
  12.  
  13.   S.Write( Name, SizeOf( Name ));
  14.   S.Write( Address, SizeOf( Address ));
  15.   S.Write( City, SizeOf( City ));
  16.   S.Write( State, SizeOf( State ));
  17.   S.Write( Zip, SizeOf( Zip ));
  18.   S.Write( Age, SizeOf( Age ));
  19.  
  20. end;
  21.  
  22.  
  23. constructor TPersonInfo.Load ( var S : TStream );
  24. begin
  25.  
  26.   S.Read( Name, SizeOf( Name ));
  27.   S.Read( Address, SizeOf( Address ));
  28.   S.Read( City, SizeOf( City ));
  29.   S.Read( State, SizeOf( State ));
  30.   S.Read( Zip, SizeOf( Zip ));
  31.   S.Read( Age, SizeOf( Age ));
  32.  
  33. end;
  34.  
  35. ...
  36.  
  37.   { Register the PersonInfo object type }
  38.   RegisterType( RPersonInfo );
  39.  
  40.   { Open the stream file }
  41.   PhoneBookFile.Init('FONEBOOK.DAT', stCreate, 1024 );
  42.  
  43.   { Tell the PhoneBook collection to put itself to the stream }
  44.   PhoneBookFile.Put( PhoneBook );
  45.  
  46.   { Close the file }
  47.   PhoneBookFile.Done;
  48.  
  49.  
  50.